import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
import AutoImport from 'unplugin-auto-import/vite'
import ElementPlus from 'unplugin-element-plus/vite'
import path from 'path'
import jsconfig from "./jsconfig.json"

const alias = (() => {
    const paths = jsconfig.compilerOptions.paths
    const temp = {}
    for (let key in paths) {
        temp[key.replace("/*", "")] = path.resolve(__dirname, paths[key][0].replace("/*", ""))
    }
    return temp
})();

// https://vitejs.dev/config/
export default defineConfig({
    resolve: {
        alias
        // extensions:['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json','.vue']
    },
    server: {
        port: 8000,
    },
    plugins: [
        vue(),
        ElementPlus(),
        // AutoImport({
        //     resolvers: [ElementPlusResolver()],
        //     imports: ['vue', 'vue-router', 'vue-i18n', '@vueuse/head', '@vueuse/core'],
        // }),
        Components({
            resolvers: [ElementPlusResolver()],
        })
    ]
})
